import jsonschema

json_data = {
    "success": True,
    "code": 10000,
    "message": "操作成功",
    "money": 6.66,
    "address": None,
    "data": {
        "name": "tom",
        "age":16.5
    },
    "luckyNumber": [6, 8, 9]
}

schema = {
    "type": "object",
    "properties": {
        "success": {"type": "boolean"},
        "code": {"type": "integer"},
        "message": {"type": "string"},
        "money": {"type": "number"},
        "address": {"type": "null"},
        "data": {"type": "object",
                 "properties": {
                     "name": {"type": "string"},
                     "age":{"type":"number"}
                 },
                 "required":["name","age"]
                 },
        "luckyNumber": {"type": "array"}
    },
    "required": ["money", "address", "data"]
}

res = jsonschema.validate(instance=json_data, schema=schema)

print("校验结果", res)
